package com.linwen.javase.desgin_pattern.BigTalkDesignPattenJAVACode._24访问者模式._1基本代码;

import java.util.ArrayList;

class ObjectStructure {
    private ArrayList<Element> elements = new ArrayList<Element>();

    public void attach(Element element) {
        elements.add(element);
    }
    public void detach(Element element) {
        elements.remove(element);
    }
    public void accept(Visitor visitor) {
        for(Element e : elements) {
            e.accept(visitor);
        }
    }
}